package com.pan.api.entity;


import java.util.ArrayList;
import java.util.List;

public class ControllerInformation extends CommentInformation {
    boolean isJsonXml;
    String prefix;
    List<MethodInformation> methodList;
    String controllerName;

    public boolean isJsonXml() {
        return isJsonXml;
    }

    public void setJsonXml(boolean jsonXml) {
        isJsonXml = jsonXml;
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public List<MethodInformation> getMethodList() {
        return methodList;
    }

    public void setMethodList(List<MethodInformation> methodList) {
        this.methodList = methodList;
        if (isJsonXml){
            methodList.forEach(api->api.setJsonXml(true));
        }
    }

    public String getControllerName() {
        return controllerName;
    }

    public void setControllerName(String controllerName) {
        this.controllerName = controllerName;
    }

    public void addApi(MethodInformation methodInformation){
        if (this.methodList == null) methodList = new ArrayList<>();
        methodList.add(methodInformation);
        if (isJsonXml) methodInformation.setJsonXml(true);
    }

    @Override
    public String toString() {
        return "ControllerInformation{" +
                "comment='" + comment + '\'' +
                ", controllerName='" + controllerName + '\'' +
                ", methodList=" + methodList +
                ", prefix='" + prefix + '\'' +
                ", isJsonXml=" + isJsonXml +
                '}';
    }
}
